# 由于1e9+7为浮点数，在取模时直接利用其会导致结果为浮点数，使得编写的程序不能通过测试用例，因而应将其转为整数。
class Solution:
    def cuttingRope(self, n: int) -> int:
        if n < 3:return 1
        if n == 3 : return 2
        three = n//3
        if n%3 == 1:
            return 3**(three-1)*4%int(1e9+7)
        elif n%3 == 2:
            return 3**three*2%int(1e9+7)
        else:
            return 3**three%int(1e9+7)
# 先统计可以分成几个3 根据余数分情况讨论
class Solution:
    def cuttingRope(self, n: int) -> int:
        if n <= 3 : return n-1
        three = n//3
        left = n%3
        if left == 1:
            return 3**(three-1)*4%int(1e9+7)
        elif left == 2:
            return 3**three*2%int(1e9+7)
        else:
            return 3**three%int(1e9+7)